﻿function comboboxInit(value, values) {
    if (!values) { return "" };
    for (var i = 0; i < values.length; i++) {
        if (values[i].id == value) {
            return values[i].name;
        }
    }
    return value;
}

function comboxChild(value,values) {
    var kxnames = [];
    for (var i = 0; i < values.length; i++) {
        if (values[i].id == value) {
            kxnames = values[i].child;
            break;
        }
    }
    return kxnames;
}

function statusMonitor() {
    var allNeedControl = $(".status-control");
    var option;
    for (var i = 0; i < allNeedControl.length; i++) {
        var showFunc = $(allNeedControl[i]).data("showFunc")
        if (typeof showFunc == "function") {
            if (showFunc()) {
                $(allNeedControl[i]).removeClass("hide");
            } else {
                $(allNeedControl[i]).addClass("hide");
            }
        }
    }
}

function collectFilter(id) {
    var finds = $('.finditem', $(id));
    var filters = [];
    for (var i = 0; i < finds.length; i++) {
        var item = $(finds[i]);
        var value = "";
        try {
            var value = item.textbox("getValue");
        } catch (e) {
            var value = item.val();
        }
        if (value != "") {
            filters.push({ name: item.data("name"), op: item.data("op"), value1: value });
        }
    }
    return filters;
}

function parseMapExResult(result) {
    if (typeof result == "string") {
        result = $.parseJSON(result);
    }
    if (!result) { $.messager.alert("信息","系统错误!"); return false; }
    if (result && result.Result == false) {
        $.messager.alert("信息", result.ErrorMessage);
        return false;
    }
    return true;
}